package FiveHomeworkDesign.Observer;

import java.util.ArrayList;
import java.util.Observer;

/**
 * @author 北巷_东坡
 * @date 2022/11/21 22:22
 * @computer 10741
 */
public abstract class Allay206 {
    protected String name;
    protected ArrayList<Observer206> membersArrayList = new ArrayList<>();

    public void join(Observer206 obs) {
        System.out.println(obs.getName() + "加入" + this.name + "联盟");
        membersArrayList.add(obs);
        obs.setAllay206(this);
    }

    public void quit(Observer206 obs) {
        System.out.println(obs.getName() + "退出" + this.name + "联盟");
        membersArrayList.remove(obs);
        obs.setAllay206(null);
    }

    public abstract void notifyMembers(String name);
}
